package light.mvc.model.admin;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import light.mvc.model.base.IdEntity;
import light.mvc.model.register.Tregister;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name = "user")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Tuser extends IdEntity implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	
	private String username;
	private String password;
	private String name;
	private String cellphone;
	private Integer age;
	private Integer sex;
	
	private String description;
	private String idNumber;
	private Date addTime;
	
	private Trole role;	
	private Tdepartment department;
	private Set<Tregister> patientRegisters = new HashSet<Tregister>(0);
	private Set<Tregister> doctorRegisters = new HashSet<Tregister>(0);

	@OneToMany(mappedBy = "patient")
	public Set<Tregister> getPatientRegisters() {
		return patientRegisters;
	}
	public void setPatientRegisters(Set<Tregister> patientRegisters) {
		this.patientRegisters = patientRegisters;
	}
	
	@OneToMany(mappedBy = "doctor")
	public Set<Tregister> getDoctorRegisters() {
		return doctorRegisters;
	}
	public void setDoctorRegisters(Set<Tregister> doctorRegisters) {
		this.doctorRegisters = doctorRegisters;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "department_id")
	public Tdepartment getDepartment() {
		return department;
	}
	public void setDepartment(Tdepartment department) {
		this.department = department;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "role_id")
	public Trole getRole() {
		return role;
	}
	public void setRole(Trole role) {
		this.role = role;
	}
	
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	@NotBlank
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@NotBlank
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@NotBlank
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@NotBlank
	public String getCellphone() {
		return cellphone;
	}
	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}
	
	@NotBlank
	public String getIdNumber() {
		return idNumber;
	}
	public void setIdNumber(String idNumber) {
		this.idNumber = idNumber;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	
}